package com.pinhuba.bams.framework.util;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;

public class MyApplication extends Application {
	private static MyApplication myApplication;

	/**
	 * Access to current global Context of the application, pay attention to use
	 * this method must be in the AndroidManifest. XML configuration
	 * MyApplication
	 * 
	 * @Title: getAppContext
	 * @return Context
	 */

	public static Context getAppContext() {
		if (null == myApplication) {
			throw new RuntimeException("Please AndroidManifest. XML configuration MyApplication");
		}
		return myApplication;
	}

	/**
	 * Access to current global Application of the Application, pay attention to
	 * use this method must be in the AndroidManifest. XML configuration
	 * MyApplication
	 * 
	 * @Title: getAppContext
	 * @return Application
	 */
	public static Application getApp() {
		if (null == myApplication) {
			throw new RuntimeException("Please AndroidManifest. XML configuration MyApplication");
		}
		return myApplication;
	}

	/**
	 * Called when the application is starting, before any other application
	 * objects have been created. Implementations should be as quick as possible
	 * (for example using lazy initialization of state) since the time spent in
	 * this function directly impacts the performance of starting the first
	 * activity, service, or receiver in a process. If you override this method,
	 * be sure to call super.onCreate().
	 */
	@Override
	public void onCreate() {
		super.onCreate();
		myApplication = this;
	}

	/**
	 * Called when the application is stopping. There are no more application
	 * objects running and the process will exit. <em>Note: never depend on
	 * this method being called; in many cases an unneeded application process
	 * will simply be killed by the kernel without executing any application
	 * code.</em> If you override this method, be sure to call
	 * super.onTerminate().
	 */
	@Override
	public void onTerminate() {

		super.onTerminate();
	}

	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
	}

	public void onLowMemory() {
		super.onLowMemory();
	}
}
